<?php

namespace app\Admin\model;

use think\Model;
use think\Db;

class Do_change extends Model
{
    public function index($data)
    {
        $username = $data['t_name'];
        $password = $data['t_pwd'];
        $relname = $data['t_relname'];
        $tid = $data['t_id'];
        for($i=0;$i<count($data['Coursename']);$i++)
                $array[$i]=$data['Coursename'][$i];
                    $str=implode(',',$array);
        
        
        $result = Db::table('teacher')->where('User_id', $tid)->Update([
                'User_name'=>$username,
                'User_password'=>$password,
                'Rel_name'=>$relname,
                'Course'=>$str,
            ]);
        //返回控制器
        if ($result) {
            return 1; //更新成功返回1
        } else {
            return 2; //更新失败返回2
        }
    }
}

?>